package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
public class Deliveryplan {
    private int deliveryId;//id
    private Integer deCustomerid;//客户id
    private Integer deContractid;//合同id
    private BigDecimal deAmount;//总金额
    private Integer dePeriod;//交付期次
    private Date deData;//计划日期
    private Integer deUserid;//所有者
    private String deDemand;//交付条件
    private Integer deRemind;//是否提醒
    private String deNote;//备注
    private List<Deliverydetails> deliverydetailsByDeliveryId;//交付计划详情
    private OrderInfo orderInfoByOrderId;//订单编号
    private Collection<Outboundorder> outboundordersByDeliveryId;//出库单详情
    private String deThere;//计划主题
    private Integer deState;//交付状态
    private Integer deApproverid;//de_approverid
    private Integer deAppstate ;//de_appstate
    private Date deNewtime;
    private Integer deFhuostate;//是否发货


    @Id
    @Column(name = "delivery_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getDeliveryId() {
        return deliveryId;
    }

    public void setDeliveryId(int deliveryId) {
        this.deliveryId = deliveryId;
    }

    @Basic
    @Column(name = "de_customerid")
    public Integer getDeCustomerid() {
        return deCustomerid;
    }

    public void setDeCustomerid(Integer deCustomerid) {
        this.deCustomerid = deCustomerid;
    }

    @Basic
    @Column(name = "de_contractid")
    public Integer getDeContractid() {
        return deContractid;
    }

    public void setDeContractid(Integer deContractid) {
        this.deContractid = deContractid;
    }

    @Basic
    @Column(name = "de_amount")
    public BigDecimal getDeAmount() {
        return deAmount;
    }

    public void setDeAmount(BigDecimal deAmount) {
        this.deAmount = deAmount;
    }

    @Basic
    @Column(name = "de_Period")
    public Integer getDePeriod() {
        return dePeriod;
    }

    public void setDePeriod(Integer dePeriod) {
        this.dePeriod = dePeriod;
    }

    @Basic
    @Column(name = "de_data")
    public Date getDeData() {
        return deData;
    }

    public void setDeData(Date deData) {
        this.deData = deData;
    }

    @Basic
    @Column(name = "de_userid")
    public Integer getDeUserid() {
        return deUserid;
    }

    public void setDeUserid(Integer deUserid) {
        this.deUserid = deUserid;
    }

    @Basic
    @Column(name = "de_demand")
    public String getDeDemand() {
        return deDemand;
    }

    public void setDeDemand(String deDemand) {
        this.deDemand = deDemand;
    }

    @Basic
    @Column(name = "de_remind")
    public Integer getDeRemind() {
        return deRemind;
    }

    public void setDeRemind(Integer deRemind) {
        this.deRemind = deRemind;
    }

    @Basic
    @Column(name = "de_note")
    public String getDeNote() {
        return deNote;
    }

    public void setDeNote(String deNote) {
        this.deNote = deNote;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Deliveryplan that = (Deliveryplan) o;
        return deliveryId == that.deliveryId &&
                Objects.equals(deCustomerid, that.deCustomerid) &&
                Objects.equals(deContractid, that.deContractid) &&
                Objects.equals(deAmount, that.deAmount) &&
                Objects.equals(dePeriod, that.dePeriod) &&
                Objects.equals(deData, that.deData) &&
                Objects.equals(deUserid, that.deUserid) &&
                Objects.equals(deDemand, that.deDemand) &&
                Objects.equals(deRemind, that.deRemind) &&
                Objects.equals(deNote, that.deNote);
    }

    @Override
    public int hashCode() {
        return Objects.hash(deliveryId, deCustomerid, deContractid, deAmount, dePeriod, deData, deUserid, deDemand, deRemind, deNote);
    }

    @OneToMany(mappedBy = "deliveryplan",cascade={CascadeType.PERSIST,CascadeType.REMOVE})//deliveryplanByDeliveryId
    public List<Deliverydetails> getDeliverydetailsByDeliveryId() {
        return deliverydetailsByDeliveryId;
    }

    public void setDeliverydetailsByDeliveryId(List<Deliverydetails> deliverydetailsByDeliveryId) {
        this.deliverydetailsByDeliveryId = deliverydetailsByDeliveryId;
    }

    @ManyToOne
    @JoinColumn(name = "order_id", referencedColumnName = "order_id")
    public OrderInfo getOrderInfoByOrderId() {
        return orderInfoByOrderId;
    }

    public void setOrderInfoByOrderId(OrderInfo orderInfoByOrderId) {
        this.orderInfoByOrderId = orderInfoByOrderId;
    }

    @OneToMany(mappedBy = "deliveryplanByDeliveryId")
    public Collection<Outboundorder> getOutboundordersByDeliveryId() {
        return outboundordersByDeliveryId;
    }

    public void setOutboundordersByDeliveryId(Collection<Outboundorder> outboundordersByDeliveryId) {
        this.outboundordersByDeliveryId = outboundordersByDeliveryId;
    }

    @Basic
    @Column(name = "de_there")
    public String getDeThere() {
        return deThere;
    }

    public void setDeThere(String deThere) {
        this.deThere = deThere;
    }

    @Basic
    @Column(name = "de_state")
    public Integer getDeState() {
        return deState;
    }

    public void setDeState(Integer deState) {
        this.deState = deState;
    }

    @Basic
    @Column(name = "de_approverid")
    public Integer getDeApproverid() {
        return deApproverid;
    }

    public void setDeApproverid(Integer deApproverid) {
        this.deApproverid = deApproverid;
    }

    @Basic
    @Column(name = "de_appstate")
    public Integer getDeAppstate() {
        return deAppstate;
    }

    public void setDeAppstate(Integer deAppstate) {
        this.deAppstate = deAppstate;
    }

    @Basic
    @Column(name = "de_newtime")
    public Date getDeNewtime() {
        return deNewtime;
    }

    public void setDeNewtime(Date deNewtime) {
        this.deNewtime = deNewtime;
    }

    @Basic
    @Column(name = " de_fhuostate")
    public Integer getDeFhuostate() {
        return deFhuostate;
    }

    public void setDeFhuostate(Integer deFhuostate) {
        this.deFhuostate = deFhuostate;
    }

    @Override
    public String toString() {
        return "Deliveryplan{" +
                "deliveryId=" + deliveryId +
                ", deCustomerid=" + deCustomerid +
                ", deContractid=" + deContractid +
                ", deAmount=" + deAmount +
                ", dePeriod=" + dePeriod +
                ", deData=" + deData +
                ", deUserid=" + deUserid +
                ", deDemand='" + deDemand + '\'' +
                ", deRemind=" + deRemind +
                ", deNote='" + deNote + '\'' +
                ", deliverydetailsByDeliveryId=" + deliverydetailsByDeliveryId +
                ", orderInfoByOrderId=" + orderInfoByOrderId +
                ", outboundordersByDeliveryId=" + outboundordersByDeliveryId +
                ", deThere='" + deThere + '\'' +
                ", deState=" + deState +
                ", deApproverid=" + deApproverid +
                ", deAppstate=" + deAppstate +
                ", deNewtime=" + deNewtime +
                ", deFhuostate=" + deFhuostate +
                '}';
    }
}





